package thread;

import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Descrip
 * tion:
 * User: Li_DaChiZi
 * Date: 2025/6/26
 * Time: 14:09
 */
public class Demo38 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(3);
        semaphore.acquire();
        System.out.println("申请一个资源");
        semaphore.acquire();
        System.out.println("申请一个资源");
        semaphore.acquire();
        System.out.println("申请一个资源");
        semaphore.release();
        System.out.println("释放一个资源");
        semaphore.acquire();
        System.out.println("申请一个资源");
    }
}
